#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include "test.h"
#include "fpga_interface.h"
#include "function_interface.h"
#include "dataBase/miscStaticDataFunction.h"
#include "dataBase/logRecordFunction.h"
#include "TableInterface/param_table_interface.h"
#include "rated_limit.h"
#include "TableInterface/lc_table_interface.h"
#include "msg_queue_pid_define.h"
#include "types.h"
#include "debug.h"
#include <pthread.h>
#include <unistd.h>
#include <sys/syscall.h>
#include "misc.h"
#include "comm_monitor.h"
#include <math.h>


static int cnt = 0;


void __attribute__((weak)) Test_OnceFunc0(void)
{
    uint16_t i;
    float fltData = 0.0F;
    uint16_t u16Data;
    ((void)(i));
    ((void)(fltData));
    ((void)(u16Data));

    PRINT_DEBUG("Ready go!");

#if 0
    for(i = 0; i < 512; i++)
    {
        if(FuncInf_DirectReadFpga(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_DirectReadFpga: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_DirectReadFpga: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 5; i++)
    {
        if(FuncInf_GetVoltage(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetVoltage: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetVoltage: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 5; i++)
    {
        if(FuncInf_GetCurrent(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetCurrent: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetCurrent: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 5; i++)
    {
        if(FuncInf_GetPower(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetPower: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetPower: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetPowerFactor(NULL, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetPowerFactor: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetPowerFactor: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetFrequency(NULL, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetFrequency: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetFrequency: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 14; i++)
    {
        if(FuncInf_GetLimit(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetLimit: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetLimit: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 15; i++)
    {
        if(FuncInf_GetStateRegister(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetStateRegister: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetStateRegister: [%d]=0x%04X", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 15; i++)
    {
        if(FuncInf_GetFaultRegister(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetFaultRegister: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetFaultRegister: [%d]=0x%04X", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetInputRegister(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetInputRegister: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetInputRegister: [%d]=0x%04X", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetOutputRegister(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetOutputRegister: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetOutputRegister: [%d]=0x%04X", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 3; i++)
    {
        if(FuncInf_GetFsm(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetFsm: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetFsm: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 9; i++)
    {
        if(FuncInf_GetCmd(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetCmd: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetCmd: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetRunMode(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetRunMode: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetRunMode: [%d]=0x%04X", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetDevState(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetDevState: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetDevState: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetGridState(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetGridState: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetGridState: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 30; i++)
    {
        if(FuncInf_GetProtectThreshold(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetProtectThreshold: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetProtectThreshold: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 11; i++)
    {
        if(FuncInf_GetAppointValue(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetAppointValue: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetAppointValue: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");
#endif

#if 0
    for(i = 0; i < 512 / 2; i++)
    {
        if(FuncInf_DirectWriteFpga(FUNCINF_OPERATOR_TEST, i, i) != 0)
            PRINT_DEBUG("FuncInf_DirectWriteFpga: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_DirectWriteFpga: [%d]=%d", i, i);
    }

    printf("\n\n\n");

    for(i = 0; i <= 11; i++)
    {
        if(FuncInf_SetLimit(FUNCINF_OPERATOR_TEST, i, i * (-1.2345F)) != 0)
            PRINT_DEBUG("FuncInf_SetLimit: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetLimit: [%d]=%f", i, i * (-1.2345F));
    }

    printf("\n\n\n");

    for(i = 0; i <= 9; i++)
    {
        if(FuncInf_SetCmd(FUNCINF_OPERATOR_TEST, i, 0xFFFF) != 0)
            PRINT_DEBUG("FuncInf_SetCmd: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetCmd: [%d]=0x%04X", i, i);
    }

    printf("\n\n\n");

    for(i = 0; i <= 9; i++)
    {
        if(FuncInf_SetCmdBit(FUNCINF_OPERATOR_TEST, i, i) != 0)
            PRINT_DEBUG("FuncInf_SetCmdBit: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetCmdBit: [%d]=0x%04X", i, i);
    }

    printf("\n\n\n");

    for(i = 0; i <= 9; i++)
    {
        if(FuncInf_ClearCmdBit(FUNCINF_OPERATOR_TEST, i, i) != 0)
            PRINT_DEBUG("FuncInf_ClearCmdBit: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_ClearCmdBit: [%d]=0x%04X", i, i);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_SetRunMode(FUNCINF_OPERATOR_TEST, NULL, FUNCINF_RUN_MODE_OL) != 0)
            PRINT_DEBUG("FuncInf_SetRunMode: Failure[%d]", FUNCINF_RUN_MODE_PQ);
        else
            PRINT_DEBUG("FuncInf_SetRunMode: [%d]=0x%04X", i, FUNCINF_RUN_MODE_PQ);
    }

    printf("\n\n\n");

    for(i = 0; i <= 30; i++)
    {
        if(FuncInf_SetProtectThreshold(FUNCINF_OPERATOR_TEST, i, i * (-1.2345F)) != 0)
            PRINT_DEBUG("FuncInf_SetProtectThreshold: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetProtectThreshold: [%d]=%f", i, i * (-1.2345F));
    }

    printf("\n\n\n");

    for(i = 0; i <= 11; i++)
    {
        if(FuncInf_SetAppointValue(FUNCINF_OPERATOR_TEST, i, i * (-1.2345F)) != 0)
            PRINT_DEBUG("FuncInf_SetAppointValue: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetAppointValue: [%d]=%f", i, i * (-1.2345F));
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_CtrlArmFaultLamp(FUNCINF_OPERATOR_TEST, NULL, FUNCINF_LAMP_ON) != 0)
            PRINT_DEBUG("FuncInf_CtrlArmFaultLamp: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_CtrlArmFaultLamp: [%d]=%d", i, FUNCINF_LAMP_ON);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_TurnOnOff(FUNCINF_OPERATOR_TEST, NULL, FUNCINF_TURN_ON) != 0)
            PRINT_DEBUG("FuncInf_TurnOnOff: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_TurnOnOff: [%d]=%d", i, FUNCINF_TURN_ON);
    }

    printf("\n\n\n");
#endif   

#if 0
    for(i = 0; i <= 17; i++)
    {
        if(FuncInf_GetIgbtTemperature(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetIgbtTemperature: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetIgbtTemperature: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 17; i++)
    {
        if(FuncInf_GetIgbtTemperatureAd(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetIgbtTemperatureAd: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetIgbtTemperatureAd: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 7; i++)
    {
        if(FuncInf_GetElectricQuantity(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetElectricQuantity: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetElectricQuantity: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 4; i++)
    {
        if(FuncInf_GetVersion(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetVersion: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetVersion: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 9; i++)
    {
        if(FuncInf_GetRatioCoef(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetRatioCoef: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetRatioCoef: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 39; i++)
    {
        if(FuncInf_GetNetParam(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetNetParam: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetNetParam: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetHmiSlaveId(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetHmiSlaveId: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetHmiSlaveId: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");    

    for(i = 0; i <= 5; i++)
    {
        if(FuncInf_GetExtremeValue(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetExtremeValue: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetExtremeValue: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetCtrlMode(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetCtrlMode: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetCtrlMode: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");    

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetMode(NULL, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetMode: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetMode: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");     

    for(i = 0; i <= 16; i++)
    {
        if(FuncInf_GetTestSwitch(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetTestSwitch: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetTestSwitch: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");     

    for(i = 0; i <= 16; i++)
    {
        if(FuncInf_GetCommunicateSwitch(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetCommunicateSwitch: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetCommunicateSwitch: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");    

    for(i = 0; i <= 16; i++)
    {
        if(FuncInf_GetStrategySwitch(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetStrategySwitch: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetStrategySwitch: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");    

    for(i = 0; i <= 10; i++)
    {
        if(FuncInf_GetArmThrshd(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetArmThrshd: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetArmThrshd: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");    

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetPwrSloped(NULL, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetPwrSloped: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetPwrSloped: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");     

    for(i = 0; i <= 23; i++)
    {
        if(FuncInf_GetPeriodParam(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetPeriodParam: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetPeriodParam: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");     

    for(i = 0; i <= 55; i++)
    {
        if(FuncInf_Get1547Param(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_Get1547Param: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_Get1547Param: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");    

    for(i = 0; i <= 19; i++)
    {
        if(FuncInf_GetDebugVal(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetDebugVal: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetDebugVal: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");      

    for(i = 0; i <= 5; i++)
    {
        if(FuncInf_GetTime(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetTime: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetTime: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");   

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetRatedPwr(NULL, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetRatedPwr: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetRatedPwr: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");     

    for(i = 0; i <= 18; i++)
    {
        if(FuncInf_GetIsoBoardData(i, &fltData) != 0)
            PRINT_DEBUG("FuncInf_GetIsoBoardData: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetIsoBoardData: [%d]=%f", i, fltData);
    }

    printf("\n\n\n");        

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_GetHeartbeat(i, &u16Data) != 0)
            PRINT_DEBUG("FuncInf_GetHeartbeat: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_GetHeartbeat: [%d]=%d", i, u16Data);
    }

    printf("\n\n\n");                                   
#endif  

#if 0
    for(i = 0; i <= 9; i++)
    {
        if(FuncInf_SetRatioCoef(FUNCINF_OPERATOR_TEST, i, i * 1.1111F) != 0)
            PRINT_DEBUG("FuncInf_SetRatioCoef: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetRatioCoef: [%d]=%f", i, i * 1.1111F);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_SetHmiSlaveId(FUNCINF_OPERATOR_TEST, NULL, 3) != 0)
            PRINT_DEBUG("FuncInf_SetHmiSlaveId: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetHmiSlaveId: [%d]=%d", i, i + 3);
    }

    printf("\n\n\n");

    for(i = 0; i <= 5; i++)
    {
        if(FuncInf_SetExtremeValue(FUNCINF_OPERATOR_TEST, i, i) != 0)
            PRINT_DEBUG("FuncInf_SetExtremeValue: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetExtremeValue: [%d]=%f", i, (float)i);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_SetCtrlMode(FUNCINF_OPERATOR_TEST, NULL, FUNCINF_CTRL_MODE_REMOTE) != 0)
            PRINT_DEBUG("FuncInf_SetCtrlMode: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetCtrlMode: [%d]=%d", i, FUNCINF_CTRL_MODE_REMOTE);
    }

    printf("\n\n\n");

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_SetMode(FUNCINF_OPERATOR_TEST, NULL, 0x0201) != 0)
            PRINT_DEBUG("FuncInf_SetMode: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetMode: [%d]=%d", i, i);
    }

    printf("\n\n\n");    

    for(i = 0; i <= 15; i++)
    {
        if(FuncInf_SetTestSwitch(FUNCINF_OPERATOR_TEST, i, i % 2) != 0)
            PRINT_DEBUG("FuncInf_SetTestSwitch: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetTestSwitch: [%d]=%d", i, i % 2);
    }

    printf("\n\n\n");      

    for(i = 0; i <= 15; i++)
    {
        if(FuncInf_SetCommunicateSwitch(FUNCINF_OPERATOR_TEST, i, i % 2) != 0)
            PRINT_DEBUG("FuncInf_SetCommunicateSwitch: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetCommunicateSwitch: [%d]=%d", i, i % 2);
    }

    printf("\n\n\n");      

    for(i = 0; i <= 15; i++)
    {
        if(FuncInf_SetStrategySwitch(FUNCINF_OPERATOR_TEST, i, i % 2) != 0)
            PRINT_DEBUG("FuncInf_SetStrategySwitch: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetStrategySwitch: [%d]=%d", i, i % 2);
    }

    printf("\n\n\n");  

    for(i = 0; i <= 10; i++)
    {
        if(FuncInf_SetArmThrshd(FUNCINF_OPERATOR_TEST, i, i * 1.1111F) != 0)
            PRINT_DEBUG("FuncInf_SetArmThrshd: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetArmThrshd: [%d]=%f", i, i * 1.1111F);
    }

    printf("\n\n\n");  

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_SetPwrSloped(FUNCINF_OPERATOR_TEST, NULL, 1.1111F) != 0)
            PRINT_DEBUG("FuncInf_SetPwrSloped: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetPwrSloped: [%d]=%f", i, 1.1111F);
    }

    printf("\n\n\n");  

    for(i = 0; i <= 23; i++)
    {
        if(FuncInf_SetPeriodParam(FUNCINF_OPERATOR_TEST, i, i * (-1.2345F)) != 0)
            PRINT_DEBUG("FuncInf_SetPeriodParam: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetPeriodParam: [%d]=%f", i, i * (-1.2345F));
    }

    printf("\n\n\n");  

    for(i = 0; i <= 55; i++)
    {
        if(FuncInf_Set1547Param(FUNCINF_OPERATOR_TEST, i, i * (-1.2345F)) != 0)
            PRINT_DEBUG("FuncInf_Set1547Param: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_Set1547Param: [%d]=%f", i, i * (-1.2345F));
    }

    printf("\n\n\n");   

    for(i = 0; i <= 19; i++)
    {
        if(FuncInf_SetDebugVal(FUNCINF_OPERATOR_TEST, i, i * (-1.2345F)) != 0)
            PRINT_DEBUG("FuncInf_SetDebugVal: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetDebugVal: [%d]=%f", i, i * (-1.2345F));
    }

    printf("\n\n\n");  

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_SetTime(FUNCINF_OPERATOR_TEST, i, 2008) != 0)
            PRINT_DEBUG("FuncInf_SetTime: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetTime: [%d]=%d", i, i);
    }

    printf("\n\n\n");  

    for(i = 1; i <= 1; i++)
    {
        if(FuncInf_SetTime(FUNCINF_OPERATOR_TEST, i, 5) != 0)
            PRINT_DEBUG("FuncInf_SetTime: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetTime: [%d]=%d", i, i);
    }

    printf("\n\n\n"); 

    for(i = 2; i <= 2; i++)
    {
        if(FuncInf_SetTime(FUNCINF_OPERATOR_TEST, i, 12) != 0)
            PRINT_DEBUG("FuncInf_SetTime: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetTime: [%d]=%d", i, i);
    }

    printf("\n\n\n"); 

    for(i = 3; i <= 3; i++)
    {
        if(FuncInf_SetTime(FUNCINF_OPERATOR_TEST, i, 14) != 0)
            PRINT_DEBUG("FuncInf_SetTime: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetTime: [%d]=%d", i, i);
    }

    printf("\n\n\n");    

    for(i = 4; i <= 4; i++)
    {
        if(FuncInf_SetTime(FUNCINF_OPERATOR_TEST, i, 28) != 0)
            PRINT_DEBUG("FuncInf_SetTime: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetTime: [%d]=%d", i, i);
    }

    printf("\n\n\n");  

    for(i = 5; i <= 5; i++)
    {
        if(FuncInf_SetTime(FUNCINF_OPERATOR_TEST, i, 4) != 0)
            PRINT_DEBUG("FuncInf_SetTime: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_SetTime: [%d]=%d", i, i);
    }

    printf("\n\n\n");   

    for(i = 0; i <= 0; i++)
    {
        if(FuncInf_Reboot(FUNCINF_OPERATOR_TEST, NULL, NULL) != 0)
            PRINT_DEBUG("FuncInf_Reboot: Failure[%d]", i);
        else
            PRINT_DEBUG("FuncInf_Reboot: [%d]=%d", i, i);
    }

    printf("\n\n\n");          
#endif  
}


void  __attribute__((weak)) Test_OnceFunc1(void)
{
    PRINT_DEBUG("Ready go!");
}


void __attribute__((weak)) Test_OnceFunc2(void)
{
    PRINT_DEBUG("Ready go!");
}


void __attribute__((weak)) Test_OnceFunc3(void)
{
    PRINT_DEBUG("Ready go!");

    // struct timeval tv;
    // unsigned long long t1, t2;

    // gettimeofday(&tv, NULL);
    // t1 = (unsigned long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
    // usleep(1000);
    // gettimeofday(&tv, NULL);
    // t2 = (unsigned long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
    // printf("t1[%llu] t2[%llu]\n", t1, t2);
    // printf("t2-t1[%llu]\n", t2 - t1);
}


void __attribute__((weak)) Test_OnceFunc4(void)
{
    PRINT_DEBUG("Ready go!");

    // uint16_t time[6] = {2008, 5, 12, 14, 28, 4};

    // FuncInf_SetTime(FUNCINF_OPERATOR_TEST, FUNCINF_TIME_TYPE_YEAR, time[0]);
    // FuncInf_SetTime(FUNCINF_OPERATOR_TEST, FUNCINF_TIME_TYPE_MON,  time[1]);
    // FuncInf_SetTime(FUNCINF_OPERATOR_TEST, FUNCINF_TIME_TYPE_DATE, time[2]);
    // FuncInf_SetTime(FUNCINF_OPERATOR_TEST, FUNCINF_TIME_TYPE_HOUR, time[3]);
    // FuncInf_SetTime(FUNCINF_OPERATOR_TEST, FUNCINF_TIME_TYPE_MIN,  time[4]);
    // FuncInf_SetTime(FUNCINF_OPERATOR_TEST, FUNCINF_TIME_TYPE_SEC,  time[5]);
    // PRINT_DEBUG("Set: %d-%d-%d %d:%d:%d", time[0], time[1], time[2], time[3], time[4], time[5]);

    // FuncInf_GetTime(FUNCINF_TIME_TYPE_YEAR, &time[0]);
    // FuncInf_GetTime(FUNCINF_TIME_TYPE_MON,  &time[1]);
    // FuncInf_GetTime(FUNCINF_TIME_TYPE_DATE, &time[2]);
    // FuncInf_GetTime(FUNCINF_TIME_TYPE_HOUR, &time[3]);
    // FuncInf_GetTime(FUNCINF_TIME_TYPE_MIN,  &time[4]);
    // FuncInf_GetTime(FUNCINF_TIME_TYPE_SEC,  &time[5]);
    // PRINT_DEBUG("Get: %d-%d-%d %d:%d:%d", time[0], time[1], time[2], time[3], time[4], time[5]);
}


void __attribute__((weak)) Test_OnceFunc5(void)
{
    PRINT_DEBUG("Ready go!");
}


void __attribute__((weak)) Test_OnceFunc6(void)
{
    PRINT_DEBUG("Ready go!");
}


void __attribute__((weak)) Test_OnceFunc7(void)
{
    PRINT_DEBUG("Ready go!");
}


void __attribute__((weak)) Test_OnceFunc8(void)
{
    PRINT_DEBUG("Ready go!");
}


void __attribute__((weak)) Test_OnceFunc9(void)
{
    PRINT_DEBUG("Ready go!");
}


void __attribute__((weak)) Test_LoopFunc0(void)
{
    uint16_t pct, reason[2] = {0};
    
    sleep(10);
#if(RATED_LIMIT_TYPE_SEL == RATED_LIMIT_TYPE_ENTIRE)
    RatedLimit_SetPercentage(cnt % 32, (100 - cnt) / 100.0F);
    sleep(5);
    RatedLimit_GetPercentage(&pct);
    RatedLimit_GetReason(0, &reason[0]);
    RatedLimit_GetReason(1, &reason[1]);
    PRINT_DEBUG("Percentage[%d%%] r0[0x%04X] r1[0x%04X]", pct, reason[0], reason[1]);
#elif(RATED_LIMIT_TYPE_SEL == RATED_LIMIT_TYPE_SEPARATE)
    RatedLimit_SetPercentage(cnt % 32, RATED_LIMIT_TYPE_CHRG, (100 - cnt) / 100.0F);
    RatedLimit_SetPercentage(cnt % 32, RATED_LIMIT_TYPE_DISC, (50 - cnt) / 100.0F);
    sleep(5);
    RatedLimit_GetPercentage(RATED_LIMIT_TYPE_CHRG, &pct);
    RatedLimit_GetReason(0, RATED_LIMIT_TYPE_CHRG, &reason[0]);
    RatedLimit_GetReason(1, RATED_LIMIT_TYPE_CHRG, &reason[1]);
    PRINT_DEBUG("Percentage[%d%%](charge) r0[0x%04X] r1[0x%04X]", pct, reason[0], reason[1]);
    RatedLimit_GetPercentage(RATED_LIMIT_TYPE_DISC, &pct);
    RatedLimit_GetReason(0, RATED_LIMIT_TYPE_DISC, &reason[0]);
    RatedLimit_GetReason(1, RATED_LIMIT_TYPE_DISC, &reason[1]);
    PRINT_DEBUG("Percentage[%d%%](discharge) r0[0x%04X] r1[0x%04X]", pct, reason[0], reason[1]);
#endif
    printf("\n");
    cnt++;
}


void __attribute__((weak)) Test_LoopFunc1(void)
{
    struct timeval tv;
    struct tm* ptm;

    gettimeofday(&tv, NULL);
    ptm = localtime (&tv.tv_sec);
    PRINT_DEBUG("%04d-%02d-%02d %02d:%02d:%02d", ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
}


void __attribute__((weak)) Test_LoopFunc2(void)
{
    float fltVal = 0.0F;
    uint16_t i;
    commState_t state;

    for(i = 0; i < 16; i++)
    {
        FuncInf_GetDebugVal(i, &fltVal);
        if(fabs(fltVal) >= 1e-6)
        {
            CommMonitor_AddHeartbeat(i);
        }
    }

    CommMonitor_GetCommState(0, &state);
    PRINT_DEBUG("[0]-%d", state);
    CommMonitor_GetCommState(8, &state);
    PRINT_DEBUG("[8]-%d", state);
}


void Test_Thread(void *pPara)
{
    Misc_InitThread(__func__);

    sleep(3);

    // Test_OnceFunc0();
    // Test_OnceFunc1();
    // Test_OnceFunc2();
    // Test_OnceFunc3();
    // Test_OnceFunc4();
    // Test_OnceFunc5();
    // Test_OnceFunc6();
    // Test_OnceFunc7();
    // Test_OnceFunc8();
    // Test_OnceFunc9();

    while(1)
    { 
        // Test_LoopFunc0();
        // Test_LoopFunc1();
        // Test_LoopFunc2();

        sleep(1);
        // usleep(100000);
    }
}

